home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
catlog
/
source
/
clip.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-08
|
7KB
|
237 lines
/*
NIFTYのLOG整理 clip.c
by GHH01217 山先
$Header: CLIP.Cv 1.2 93/02/12 22:44:20 山先 Exp $
*/
#include "log.h"
#define TEST 1
#undef TEST
/****************************************************************************
>123456789 123456789 123456789
>クリッピングサービス CLIP
*****************************************************************************/
int isCLIPFirstLine()
{
IFPStrEqu("クリッピングサービス CLIP",28) return( YES );
/*
IFPStrEqu("番号 提供日付 題名",26) return( YES );
*/
return( NO );
}
/****************************************************************************
> 1 2 3 4 5
> 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234
>番号 提供日付 題名
> 1 1/08 15:09 時: ◎CDROMで特許出願公開
> 2 1/08 12:01 時: ◎松下、米ベンチャー企業に出資
*****************************************************************************/
static int isCLIPLine_sub( const char *str , int len )
{
if ( len < 24 ) return( NO );
if ( ! isdigit( str[ 2 ] ) ) return( NO ); /* 番号 */
if ( ! isdigit( str[ 7 ] ) ) return( NO ); /* 月 */
if ( str[ 8 ] != '/' ) return( NO );
if ( check_digit( 9 , 10 ) == NO ) return( NO ); /* 日 */
if ( str[ 11 ] != ' ' ) return( NO );
if ( check_digit( 12 , 13 ) == NO ) return( NO ); /* 時 */
if ( str[ 14 ] != ':' ) return( NO );
if ( check_digit( 15 , 16 ) == NO ) return( NO ); /* 分 */
if ( str[ 17 ] != ' ' ) return( NO );
if ( str[ 21 ] != ' ' ) return( NO );
return( YES );
}
int isCLIPStr( const char *str )
{
return( isCLIPLine_sub( str , strlen( str ) ) );
}
int isCLIPLine()
{
return( isCLIPLine_sub( PresentStrPtr , PresentStrLen ) );
}
/****************************************************************************
> 1 2 3 4 5
> 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234
>[1993-01-08-15:09]
>続き (改行で次文書 E:終了)
>表示終了
*****************************************************************************/
int isCLIPEnd()
{
int len;
char *str;
IFPStrEqu("続き (改行で次文書 E:終了)",27) return( YES );
IFPStrEqu("表示終了",8) return( YES );
if ( isCLIPFirstLine() == YES ) return( YES );
if ( isCLIPLine() == YES ) return( YES );
return( NO );
str = PresentStrPtr; len = PresentStrLen;
if ( len != 18 ) return( NO );
if ( str[ 0 ] != '[' ) return( NO );
if ( check_digit( 1 , 4 ) == NO ) return( NO ); /* 年 */
if ( str[ 5 ] != '-' ) return( NO );
if ( check_digit( 6 , 7 ) == NO ) return( NO ); /* 月 */
if ( str[ 8 ] != '-' ) return( NO );
if ( check_digit( 9 , 10 ) == NO ) return( NO ); /* 日 */
if ( str[ 11 ] != '-' ) return( NO );
if ( check_digit( 12 , 13 ) == NO ) return( NO ); /* 時 */
if ( str[ 14 ] != ':' ) return( NO );
if ( check_digit( 15 , 16 ) == NO ) return( NO ); /* 分 */
if ( str[ 17 ] != ']' ) return( NO );
return( YES );
}
static void check_clip_skip()
{
forever {
IFPStrEqu2(">",2) break;
GET_LINE;
};
GET_LINE; /* 先読み */
}
void check_clip_main()
{
print_start_line(); /* *PresentStrPtr を YELLOW で表示 */
GET_LINE;
check_clip_skip();
check_clip_skip();
check_skip_useless_line();
while ( isCLIPLine() == YES ) {
check_pool_delete_start = PresentStrPtr;
/* フォーラム名 */
strcpy( forum_name , "CLIP" ); /* フォーラム名 */
kaigishitsu_number = CLIP; /* 会議室番号 */
hatsugen_number = atoi( PresentStrPtr ); /* 発言番号 */
set_hatsugen_date_clip( PresentStrPtr ); /* 日付 sub.c */
comment_number = 0; /* コメント先番号 */
*collect_id = '\0'; /* 発言の収集 */
present_str_copy( forum_name_line );
*forum_sub_name_line = '\0';
check_save_start_sub();
GET_LINE; check_set_lib_number();
while ( isCLIPLine() != YES ) {
GET_LINE2 break; check_set_lib_number();
if ( check_check_end() == YES ) break;
};
/* 本文を書き出す */
catlog_fwrite();
check_skip_useless_line();
};
}
/*********************************************************************/
/*************************** 第3段階 ******************************/
/*********************************************************************/
static int is_clip_index( )
{
int sw;
FILE *fp;
set_index_file_name( "CLIP" ); /* file.c */
sw = NO;
if ( ( fp = fopen( file_name , "r" ) ) != NULL ) {
while( fgets( str , LINE , fp ) != NULL ) {
without_crlf( str );
if ( strcmp( str + 3 , forum_name_line + 3 ) == 0 ) {
sw = YES;
break;
};
};
};
fclose( fp );
return( sw );
}
static void catlog_clip_skip_data()
{
while ( strncmp( str , "*****log整理" , 12 ) != 0 ) {
if ( fgets( str , LINE , catlog_fpi ) == NULL ) break;
};
}
static void catlog_clip_append_index( )
{
FILE *index_fpo;
set_index_file_name( "CLIP" ); /* file.c */
if ( ( index_fpo = fopen( file_name , "a" ) ) == NULL ) {
error_open_file( "catlog_clip_append_index()" );
error_end();
};
fprintf( index_fpo , "%s\n" , forum_name_line );
fclose( index_fpo );
}
void catlog_clip_main( char *catlog_findfirst_path , const char *file )
{
int sw , cr_sw;
*forum_sub_name_line = '\0';
/* 入力ファイルのオープン */
catlog_fpi = fopen( file , "r" );
fgets( str , LINE , catlog_fpi ); /* 先読み */
sw = TRUE;
while ( strncmp( str , "*****log整理" , 12 ) == 0 ) {
strcpy( partition_line , str );
fgets( str , LINE , catlog_fpi ); /* ID名 フォーラム名 */
fgets( str , LINE , catlog_fpi ); /* 会議室番号 */
fgets( str , LINE , catlog_fpi ); /* 発言番号 */
fgets( str , LINE , catlog_fpi ); /* 日付 */
fgets( str , LINE , catlog_fpi ); /* コメント番号 */
fgets( str , LINE , catlog_fpi ); /* ID収集? */
fgets( str , LINE , catlog_fpi ); /* <………> FFMHOB */
without_crlf( str );
/* フォーラム名の設定。 null の場合もある */
strcpy( forum_name_line , str );
fgets( str , LINE , catlog_fpi ); /* forum_sub_name_line */
/* 登録済かチェック */
if ( is_clip_index( ) == YES ) {
catlog_clip_skip_data(); continue;
};
/* インデックスに登録する */
catlog_clip_append_index( catlog_findfirst_path );
/* catlog_fpo をオープンする */
open_save_data_file( 0 , NO );
/* *****log整理~~を出力する */
if ( no_partition_line_sw != YES ) {
fprintf( catlog_fpo , "%s" , partition_line );
};
fgets( str , LINE , catlog_fpi ); /* 先読み */
forever {
fprintf( catlog_fpo , "%s" , str );
if ( *str == '\n' ) { cr_sw = YES;
} else { cr_sw = NO;
};
if ( fgets( str , LINE , catlog_fpi ) == NULL ) {
sw = FALSE;
break;
};
if ( strncmp( str , "*****log整理" , 12 ) == 0 ) break;
};
if ( cr_sw == NO ) fputc( '\n' , catlog_fpo );
fclose( catlog_fpo );
hatugen_su++;
if ( sw == FALSE ) break;
};
fclose( catlog_fpi );
}